<template>
  <div class="flex flex-column list-content" v-if="list?.length">
      <PersonT
          class="job-person" :people="item"
          v-for="(item, index) in list"
          @btn="bindTel(item)"
      ></PersonT>
  </div>

  <NoData v-if="errMsg">
    <div  style="color: #0D3333;" @click="bindCompany">{{errMsg}}, <span style="color: #24FAF6">立即去注册>>></span></div>
  </NoData>

  <ModelMaks ref="priceMaksRef" title="获取提醒" :show-close="true" @submit="showCompany">
    <div  style="color: #0D3333;" >确定消耗{{errMsg}}
      <span style="display:inline-block; background: #24FAF6; width: 20px;height: 20px;border-radius: 50%; text-align: center; line-height: 20px">{{priceObj[0]?.price}}</span>
      能量获取 <span style="font-weight: bold;">{{activeUser.resume.name}}</span> 的联系方式
    </div>
  </ModelMaks>

    <ModelMaks ref="modelMaksRef" title="联系方式" @submit="copyCompany">
    <div class="tel-ipt">
      <div class="label">联系电话</div>
      <div class="value">{{ telUser.tel }}</div>
      <image class="icon" src="/static/img/telaa.png"></image>
    </div>
    <div class="tel-ipt">
      <div class="label">微信号</div>
      <div class="value">{{ telUser.wx_num }}</div>
      <image class="icon" src="/static/img/wechata.png"></image>
    </div>
  </ModelMaks>
</template>

<script setup lang="ts">
import useQueryPage from "../../hooks/useQueryPage";
import {getContact_data, getPrice_data, members_data} from "../../api/Job";
import ModelMaks from "../../components/ModelMaks.vue";
import {onMounted, shallowRef, watch} from "vue";
import {goUrl} from "../../utils/UniUtil";
import NoData from "../../components/NoData.vue";
import PersonT from "../../components/PersonT.vue";

const {page, list, loading, errMsg} = useQueryPage(members_data, {})

const modelMaksRef = shallowRef();
const priceMaksRef = shallowRef();

watch(errMsg, () => {

})

const bindCompany = () => {
  goUrl('/pages/company/push')
}

const priceObj = shallowRef({});

onMounted(() => {
  getPrice_data({}).then(res => {
    priceObj.value = res
  })
})

const activeUser = shallowRef({})
const bindTel = (item) => {
  activeUser.value = item;
  priceMaksRef.value?.showModel();
}

const telUser = shallowRef({});
const showCompany = () => {
  getContact_data(activeUser.value.id).then(res => {
    telUser.value = res;
    modelMaksRef.value?.showModel();
  }).catch(res => {
    console.log('errr', res)
  })
}

const copyCompany = () => {
  telUser.value = {}
}
</script>

<style lang="scss" scoped>

.input-filter {
  display: flex;
  align-items: center;
  height: 68px;
  padding: 0 42rpx;
  .ipt {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    height: 68rpx;
    background: rgba(255,255,255,0.06);
    border-radius: 28px;
    border: 2px solid rgba(0,0,0,0.12);
    padding: 0 40rpx;
    input {
      flex: 1;
      height: 68rpx;
      font-size: 26rpx;
      font-weight: 300;
      line-height: 68rpx;
    }
    .icon {
      font-size: 28px;
      color: #0D3333;
    }
  }
  .filter {
    display: flex;
    align-items: center;
    margin-left: 40rpx;
    flex: 0 1 auto;
    span{
      height: 44rpx;
      font-size: 32rpx;
      font-weight: 300;
      color: #0D3333;
      line-height: 44rpx;
    }
  }
}

.list-content {
  background: #F7F7F7;
  padding: 32rpx;
  gap: 24rpx;
  .job-person {
    display: flex;
    flex-flow: column;
    gap: 24rpx
  }
}

.tel-ipt {
  display: flex;
  align-items: center;
  justify-content: center;
  .label {
    width: 104rpx;
    height: 34rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #0D3333;
    line-height: 34rpx;
    text-align: right;
  }
  .value {
    width: 318rpx;
    height: 42rpx;
    background: rgba(36, 250, 246, 0.38);
    border-radius: 16rpx;
    font-size: 24rpx;
    font-weight: 600;
    color: #0D3333;
    line-height: 42rpx;
    margin: 16rpx;
    padding: 0 20rpx;
  }
  .icon {
    width: 42rpx;
    height: 42rpx;
  }
}
</style>
